package team.fourth.combat.web;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import team.fourth.combat.commen.entity.PageResult;
import team.fourth.combat.commen.entity.QueryPageBean;
import team.fourth.combat.commen.entity.Result;
import team.fourth.combat.pojo.CheckGroup;
import team.fourth.combat.service.CheckGroupService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/checkgroup")
public class CheckGroupController {

    @Reference(cluster = "failfast")
    CheckGroupService checkGroupService;

//    public Result add(@RequestBody CheckGroup checkGroup, List<Integer> checkitemIds ){
//
//    }
    @RequestMapping("/add")
    public Result add(@RequestBody CheckGroup checkGroup){
        checkGroupService.add(checkGroup);
        return Result.success("");
    }

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return checkGroupService.findPage(queryPageBean);
    }

    @RequestMapping("/findAll")
    public Result findAll(){
        List<CheckGroup> checkGroups = checkGroupService.findAll();
        return Result.success("",checkGroups);
    }

    @RequestMapping("/findById")
    public Result findById(Integer id){
       Map map =  checkGroupService.findById(id);
       return Result.success("",map);
    }

    @RequestMapping("/edit")
    public Result edit(@RequestBody CheckGroup checkGroup){
        checkGroupService.edit(checkGroup);
        return Result.success("");
    }
}
